import Vue from 'vue'
import VueRouter from 'vue-router'
import Header from '../components/Header.vue'
import Footer from '../components/Footer.vue'

import Home from '../views/Home.vue'
import Search from '../views/Search.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/search',
    name: 'Search',
    meta:{
      title:"搜索",
      show:false
    },
    component: Search,
  },
  {
    path: '/footer',
    name: 'Footer',
    meta:{
      title:"页尾"
    },
    component: Footer,
  },
  {
    path: '/header',
    name: 'Header',
    meta:{
      title:"头部"
    },
    component: Header,
  },
  {
    path: '/',
    name: 'Home',
    meta:{
      title:"首页",
      show:true
    },
    component: Home
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
//守卫
router.beforeEach((to,from,next)=>{
  document.title=to.meta.title
  next()
})

export default router
